Learn R Programming

Compositional (version 4.4)

Log-contrast regression with compositional predictor variables: Log-contrast regression with compositional predictor variables

Description

Log-contrast regression with compositional predictor variables.

Usage

lc.reg(y, x, xnew = NULL)

Arguments

y

A numerical vector containing the response variable values. This must be a continuous variable.

x

A matrix with the predictor variables, the compositional data. No zero values are allowed.

xnew

A matrix containing the new compositional data whose response is to be predicted. If you have no new data, leave this NULL as is by default.

Value

A list tincluding:

be

The constrained regression coefficients. Their sum equals 0.

covbe

If covariance matrix of the constrained regression coefficients.

va

The estimated regression variance.

residuals

The vector of residuals.

est

If the argument "xnew" was given these are the predicted or estimated values, otherwise it is NULL.

Details

The function performs the log-contrast regression model as described in Aitchison (2003), pg. 84-85. The logarithm of the compositional predictor variables is used (hence no zero values are allowed). The response variable is linked to the log-transformed data with the constraint that the sum of the regression coefficients equals 0. Hence, we apply constrained least squares, which has a closed form solution.

The constrained least squares is described in Chapter 8.2 of Hansen (2019). The idea is to inimise the sum of squares of the residuals under the constraint \(R^T \beta = c\).

References

Aitchison J. (1986). The statistical analysis of compositional data. Chapman \& Hall.

Hansen, B. E. (2019). Econometrics. https://www.ssc.wisc.edu/~bhansen/econometrics/Econometrics.pdf

See Also

alfa.pcr, alfa.knn.reg

Examples

Run this code
# NOT RUN {
y <- iris[, 4]
x <- as.matrix(iris[, 1:3])
x <- x / rowSums(x)
mod <- lc.reg(y, x)
# }

Run the code above in your browser using DataLab